package com.wang.vedio.adapter.index;

import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.MultiTransformation;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wang.vedio.R;
import com.wang.vedio.bean.DetailsCommentBean;
import com.wang.vedio.net.rxjava.HttpMethods;
import com.wang.vedio.utils.StringUtils;

import java.util.List;

public class DetailsCommentAdapter extends BaseQuickAdapter<DetailsCommentBean, BaseViewHolder> {
    public DetailsCommentAdapter(int layoutResId, @Nullable List<DetailsCommentBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, DetailsCommentBean item) {
        helper.setText(R.id.iv_nick_name, StringUtils.toString(item.getMemberName()))
        .setText(R.id.iv_time,item.getAddDate())
        .setText(R.id.content,item.getContent());
        ImageView imageView = helper.getView(R.id.iv_avatar);
        if(StringUtils.isEmpty(item.getHeadPic())){
            imageView.setImageResource(R.mipmap.head_pic);
        }else{
            Glide.with(imageView)
                    .load(HttpMethods.BASE_URL+item.getHeadPic())
                    .apply(RequestOptions.bitmapTransform(new MultiTransformation<>(new CenterCrop(), new RoundedCorners(40))))
                    .into(imageView);
        }
    }
}
